From: Tamas K Lengyel Date: Mon, 20 Apr 2015 15:06:23 +0000 (+0200) Subject: tools/tests: Enable xen-access on ARM X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~3391 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=f076b568c68c99bd722207a1732564ff5e047180;p=xen.git tools/tests: Enable xen-access on ARM Switch to use maximum gpfn as the limit to setting permissions. Also, move HAS_MEM_ACCESS definition into config. Signed-off-by: Tamas K Lengyel Acked-by: Ian Campbell [ ijc -- removed obsolete reference to test_and_set_bit from the commit message ] --- diff --git a/tools/tests/xen-access/Makefile b/tools/tests/xen-access/Makefile index f0e94fd860..f810543738 100644 --- a/tools/tests/xen-access/Makefile +++ b/tools/tests/xen-access/Makefile @@ -7,8 +7,8 @@ CFLAGS += $(CFLAGS_libxenctrl) CFLAGS += $(CFLAGS_libxenguest) CFLAGS += $(CFLAGS_xeninclude) -TARGETS-y := -TARGETS-$(CONFIG_X86) += xen-access +TARGETS-y := +TARGETS-$(HAS_MEM_ACCESS) := xen-access TARGETS := $(TARGETS-y) .PHONY: all diff --git a/tools/tests/xen-access/xen-access.c b/tools/tests/xen-access/xen-access.c index 8a899da0a5..12ab921350 100644 --- a/tools/tests/xen-access/xen-access.c +++ b/tools/tests/xen-access/xen-access.c @@ -41,6 +41,13 @@ #include #include +#if defined(__arm__) || defined(__aarch64__) +#include +#define START_PFN (GUEST_RAM0_BASE >> 12) +#elif defined(__i386__) || defined(__x86_64__) +#define START_PFN 0ULL +#endif + #define DPRINTF(a, b...) fprintf(stderr, a, ## b) #define ERROR(a, b...) fprintf(stderr, a "\n", ## b) #define PERROR(a, b...) fprintf(stderr, a ": %s\n", ## b, strerror(errno)) @@ -57,7 +64,7 @@ typedef struct vm_event { typedef struct xenaccess { xc_interface *xc_handle; - xc_domaininfo_t *domain_info; + xen_pfn_t max_gpfn; vm_event_t vm_event; } xenaccess_t; @@ -165,7 +172,6 @@ int xenaccess_teardown(xc_interface *xch, xenaccess_t *xenaccess) } xenaccess->xc_handle = NULL; - free(xenaccess->domain_info); free(xenaccess); return 0; @@ -243,23 +249,18 @@ xenaccess_t *xenaccess_init(xc_interface **xch_r, domid_t domain_id) (vm_event_sring_t *)xenaccess->vm_event.ring_page, XC_PAGE_SIZE); - /* Get domaininfo */ - xenaccess->domain_info = malloc(sizeof(xc_domaininfo_t)); - if ( xenaccess->domain_info == NULL ) - { - ERROR("Error allocating memory for domain info"); - goto err; - } + /* Get max_gpfn */ + rc = xc_domain_maximum_gpfn(xenaccess->xc_handle, + xenaccess->vm_event.domain_id, + &xenaccess->max_gpfn); - rc = xc_domain_getinfolist(xenaccess->xc_handle, domain_id, 1, - xenaccess->domain_info); - if ( rc != 1 ) + if ( rc ) { - ERROR("Error getting domain info"); + ERROR("Failed to get max gpfn"); goto err; } - DPRINTF("max_pages = %"PRIx64"\n", xenaccess->domain_info->max_pages); + DPRINTF("max_gpfn = %"PRIx64"\n", xenaccess->max_gpfn); return xenaccess; @@ -422,8 +423,9 @@ int main(int argc, char *argv[]) goto exit; } - rc = xc_set_mem_access(xch, domain_id, default_access, 0, - xenaccess->domain_info->max_pages); + rc = xc_set_mem_access(xch, domain_id, default_access, START_PFN, + (xenaccess->max_gpfn - START_PFN) ); + if ( rc < 0 ) { ERROR("Error %d setting all memory to access type %d\n", rc, @@ -450,8 +452,8 @@ int main(int argc, char *argv[]) /* Unregister for every event */ rc = xc_set_mem_access(xch, domain_id, XENMEM_access_rwx, ~0ull, 0); - rc = xc_set_mem_access(xch, domain_id, XENMEM_access_rwx, 0, - xenaccess->domain_info->max_pages); + rc = xc_set_mem_access(xch, domain_id, XENMEM_access_rwx, START_PFN, + (xenaccess->max_gpfn - START_PFN) ); rc = xc_monitor_software_breakpoint(xch, domain_id, 0); shutting_down = 1;